﻿using NewBeeTools.DB.SqlSugar;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NewBeeTools.DB
{
    public class MemoryDB
    {
        public static SqliteInMemorySugarClient db = new SqliteInMemorySugarClient(new ConnectionConfig
        {
            DbType = DbType.Sqlite,
            InitKeyType = InitKeyType.Attribute,
            ConfigureExternalServices = new ConfigureExternalServices()
            {
                SqlFuncServices = ExtMethods.GetExpMethods
            },
            AopEvents = new AopEvents
            {
                OnLogExecuting = (sql, p) =>
                {
                    Console.WriteLine(sql);
                    Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
                }
            }
        });
    }
}
